<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>mixin_merge</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
    <div id="app">
    </div>
    <script>
        var mixin = {
            data: function(){
                return {
                    message: 'hello',
                    foo: 'abc'
                };
            },
            created: function(){
                console.log('混入对象的钩子被调用');
            }
        };

        new Vue({
            mixins: [mixin],
            data: function() {
                return {
                    message: 'goodbye',
                    bar: 'def'
                }
            },
            created: function() {
                console.log('组件钩子被调用');
                console.log(this.$data);
                console.log(this.$data.foo);
                console.log(this.$data.message);
                console.log(this.$data.bar);
            }
        });
    </script>
</body>
</html>
